{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>机构列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->
            <div class="row">
                <div class="col-sm-12">
                    <div  class="col-sm-2" style="width: 100px">
                        <div class="input-group" >
                            <a href="{:url('add')}"><button class="btn btn-outline btn-primary" type="button">添加机构</button></a>
                        </div>
                    </div>
                </div>
            </div>
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover">
                        <thead>
                        <tr class="long-tr">
                            <th>ID</th>
                            <th>名称</th>
                            <th>排序</th>
                            <th>状态</th>
                            <!--<th width="15%">添加时间</th>-->
                            <!--<th width="15%">更新时间</th>-->
                            <th width="20%">操作</th>
                        </tr>
                        </thead>
                        <tbody id="article_list">
                        {foreach name="list" item="vo"}
                        <tr class="long-td">
                            <td>{$vo.id}</td>
                            <td>{$vo.name}</td>
                            <td>{$vo.sort}</td>
                            <td>
                                {if condition="$vo['status'] == 1"}
                                <a href="javascript:;" onclick="instit_state({$vo.id});">
                                    <div id="zt{$vo.id}"><span class="label label-info">开启</span></div>
                                </a>
                                {else/}
                                <a href="javascript:;" onclick="instit_state({$vo.id});">
                                    <div id="zt{$vo.id}"><span class="label label-danger">禁用</span></div>
                                </a>
                                {/if}
                            </td>
                            <!--<td>{$vo.create_time}</td>-->
                            <!--<td>{$vo.update_time}</td>-->
                            <td>
                                <a href="{:url('edit',['id'=>$vo.id])}" class="btn btn-primary btn-xs">
                                    <i class="fa fa-paste"></i> 编辑</a>&nbsp;&nbsp;

                            </td>
                        </tr>
                        {/foreach}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>
{include file="public/footer" /}


<script type="text/javascript">

    /**
     * [del 删除用户]
     * @Author[沈晶晶 334554156@qq.com]
     * @param   {[type]}    id [用户id]
     */
//    function del_cate(id){
//        layer.confirm('确认删除此机构?', {icon: 3, title:'提示'}, function(index){
//            //do something
//            $.getJSON('./del_cate', {'id' : id}, function(res){
//                if(res.code == 1){
//                    layer.msg(res.msg,{icon:1,time:1500,shade: 0.1},function(){
//                        window.location.href="{:url('article/index_cate')}";
//                    });
//                }else{
//                    layer.msg(res.msg,{icon:0,time:1500,shade: 0.1});
//                }
//            });
//
//            layer.close(index);
//        })
//
//    }

    /**
     * [user_state 用户状态]
     * @param  {[type]} val [description]
     * @Author[沈晶晶 334554156@qq.com]
     */
    function instit_state(val){
        $.post('{:url("instit_state")}',
                {id:val},
                function(data){

                    if(data.code==1){
                        var a='<span class="label label-danger">禁用</span>'
                        $('#zt'+val).html(a);
                        layer.msg(data.msg,{icon:2,time:1500,shade: 0.1,});
                        return false;
                    }else{
                        var b='<span class="label label-info">开启</span>'
                        $('#zt'+val).html(b);
                        layer.msg(data.msg,{icon:1,time:1500,shade: 0.1,});
                        return false;
                    }

                });
        return false;



    }


</script>
</body>
</html>